package com.biz.controller.sys;

import com.framework.controller.BaseController;
import com.framework.util.SmsUtil;
import com.framework.util.Tools;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by lzq.
 */
@Controller
@RequestMapping(value="/sys")
public class SysController extends BaseController{

    /**
     * 发送短信验证码
     *
     * @param mobile
     *            接收手机号码
     * @throws Exception
     */
    @RequestMapping("/sendMsg")
    public void sendMsg(String mobile, HttpServletResponse response)
            throws Exception {
		/* 生成6位随机数 */
        String code = Tools.getRandomNum() + "";
        Map<String, String> map = new HashMap<String, String>();
        // String msgContent="您的验证码为:"+code;
        SmsUtil.sendMsg(mobile, code);
        System.out.println("========手机号:" + mobile + "========验证码:" + code);
        map.put("phone", mobile);
        map.put("code", code);
       writeJson(map,response);
    }

}
